package com.neusoft.boot32.dibuy.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.neusoft.boot32.dibuy.entity.Author;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
class AuthorMapperTest {
    @Autowired
    AuthorMapper authorMapper;

    @Test
    void selectAllAuthors() {
        List<Author> authors = authorMapper.selectList(null);
        authors.forEach(System.out::println);
    }

    @Test
    void selectAuthorById() {
        Author author = authorMapper.selectById(1);
        System.out.println(author);
    }

    @Test
    void selectAuthorWrapper() {
        LambdaQueryWrapper<Author> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq( Author::getId,1);
        Author author = authorMapper.selectOne(wrapper);
        System.out.println(author);
    }

    @Test
    void selectAuthorWrapperLike() {
        LambdaQueryWrapper<Author> wrapper = new LambdaQueryWrapper<>();
        wrapper.likeLeft(Author::getName,"aa");
        List<Author> authors =   authorMapper.selectList(wrapper);
        authors.forEach(System.out::println);
    }







}